package game.resource.loader.tagparser;

import org.xml.sax.Attributes;

import common.Log;
import common.Rectangle;

public class ClipTagParser implements TagParser_I {
	public Rectangle ClipRect;
	@Override
	public boolean parse(String tag, Attributes attributes) {
		if(!tag.toLowerCase().equals("clip")) {
			return false;
		}

		int x, y, w, h;
		try {
			x = Integer.parseInt(attributes.getValue("x"));
			y = Integer.parseInt(attributes.getValue("y"));
			w = Integer.parseInt(attributes.getValue("width"));
			h = Integer.parseInt(attributes.getValue("height"));
		} catch (NumberFormatException e) {
			Log.warning("Bad format of clip rectangle string.");
			return false;
		}
		ClipRect = new Rectangle(x, y, w, h);
		return true;
	}
}
